home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / circuits / irsim-9.000 / irsim-9 / src / irsim / intr.c < prev    next >
C/C++ Source or Header  |  1993-01-15  |  2KB  |  57 lines

  1. /* 
  2.  *     ********************************************************************* 
  3.  *     * Copyright (C) 1988, 1990 Stanford University.                     * 
  4.  *     * Permission to use, copy, modify, and distribute this              * 
  5.  *     * software and its documentation for any purpose and without        * 
  6.  *     * fee is hereby granted, provided that the above copyright          * 
  7.  *     * notice appear in all copies.  Stanford University                 * 
  8.  *     * makes no representations about the suitability of this            * 
  9.  *     * software for any purpose.  It is provided "as is" without         * 
  10.  *     * express or implied warranty.  Export of this software outside     * 
  11.  *     * of the United States of America may require an export license.    * 
  12.  *     ********************************************************************* 
  13.  */
  14.  
  15. #include <signal.h>
  16. #include <stdio.h>
  17. #include <defs.h>
  18.  
  19. #ifdef SYS_V
  20. #    ifndef hpux
  21. #    define    signal( SIG, HAND )    sigset( SIG, HAND )
  22. #    endif
  23. #endif
  24.  
  25.  
  26. public    int    int_received = 0;
  27.  
  28.  
  29. private void int_handler()
  30.   {
  31.     if( int_received == 1 )
  32.     (void) fprintf( stderr, "\nok ... wait a second\n" );
  33.     if( int_received <= 1 )
  34.     int_received++;
  35.  
  36. #ifdef SYS_V
  37.     (void) signal( SIGINT, int_handler );
  38. #endif
  39.   }
  40.  
  41.  
  42. private void bye_bye()
  43.   {
  44.     extern void TerminateAnalyzer();
  45.  
  46.     TerminateAnalyzer();
  47.     exit( 0 );
  48.   }
  49.  
  50.  
  51. public void InitSignals()
  52.   {
  53.     (void) signal( SIGQUIT, SIG_IGN );            /* ignore quit */
  54.     (void) signal( SIGINT, int_handler );
  55.     (void) signal( SIGHUP, bye_bye );            /* for magic's sake */
  56.   }
  57.